<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>no.priv.bang.xml.schema</groupId>
    <artifactId>convert-xsd-to-rnc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>xsd to rnc conversion</name>
    <description>Use Oracle Multi Schema Validator and trang to convert liquibase XSD schema to Relax-NG compact notation</description>
    <properties>
        <liquibase-xsd.version>4.32</liquibase-xsd.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>net.java.dev.msv</groupId>
            <artifactId>msv-rngconverter</artifactId>
            <version>2022.7</version>
        </dependency>
        <dependency>
            <groupId>org.relaxng</groupId>
            <artifactId>trang</artifactId>
            <version>20241231</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <classpathScope>test</classpathScope>
                </configuration>
                <executions>
                    <execution>
                        <id>convert-liquibase-xsd-to-rng</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.sun.msv.writer.relaxng.Driver</mainClass>
                            <commandlineArgs>
                                ${project.build.directory}/dependency/www.liquibase.org/xml/ns/dbchangelog/dbchangelog-${liquibase-xsd.version}.xsd
                                ${project.build.directory}/dbchangelog-${liquibase-xsd.version}.rng
                            </commandlineArgs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>convert-liquibase-rng-to-rnc-no-version</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.thaiopensource.relaxng.translate.Driver</mainClass>
                            <blockSystemExit>true</blockSystemExit>
                            <arguments>
                                <argument>${project.build.directory}/dbchangelog-${liquibase-xsd.version}.rng</argument>
                                <argument>${project.build.directory}/dbchangelog-${liquibase-xsd.version}.rnc</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-liquibase-xsd</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.liquibase</groupId>
                                    <artifactId>liquibase-core</artifactId>
                                    <version>LATEST</version>
                                </artifactItem>
                            </artifactItems>
                            <includes>**/dbchangelog-*.xsd</includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
